function mergeSortedArrays(arr1, arr2) {
  let i = 0;
  let j = 0;
  let res = []
  
  while(i<arr1.length && j<arr2.length) {
    if(arr1[i]<arr2[j]) {
      res.push(arr1[i++])
    }else{
      res.push(arr2[j++])
    }
  }
  while(i<arr1.length) res.push(arr1[i++])
  while(j<arr2.length) res.push(arr2[j++])
  return res
}
const a1 = [1,3,8,17,90]
const a2 = [2,4,23,35]
console.log(mergeSortedArrays(a1,a2))